home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4756 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Compiler error on long multiplication?
  5. Date: 6 Feb 1996 16:18:08 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4f8gig$3uc@umbc9.umbc.edu>
  8. References: <4f4fr0$pea@newnews.iafrica.com>
  9. NNTP-Posting-Host: umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. Pieter Malan  <vizier@iafrica.com> wrote:
  13. |> This code was compiled with 3.1.
  14.  
  15. With 3.1 what? Is that a version of a compiler and if so what one...
  16.  
  17. |> When compiled for 80386, the one onswer is wrong as indicated.
  18.  
  19. Please elaborate...I do not see any printf() statements in your code
  20. which leads to my question of HOW you know the value of the incorrect
  21. variable.
  22.  
  23. |> For all other processors the answer is correct.  WHY??
  24.  
  25. You mean you have compiled this code on every single processor currently
  26. known to exist? I doubt that ;-).
  27.  
  28. Don't forget to #include <stdio.h> if you are doing any I/O.
  29.  
  30. |> void main()
  31.  
  32. Surely 'int main (void)' was intended.
  33.  
  34. |> {
  35. |> unsigned long a;  //OR SIGNED
  36.  
  37. C++ comments are not supported on strict ANSI C compilers.
  38.  
  39. |> unsigned long x;
  40. |> 
  41. |>         a = 1;
  42. |>         x = (a * 100L) * 100L;    // x = 13379344 WRONG!!!
  43.  
  44. printf ("%lu\n", x); /* Gave me 10000 as expected */
  45.  
  46. |>         a = 100;
  47. |>         x = a * 100L;        // x = 10000
  48.  
  49. More naughty C++ comments...
  50.  
  51. printf ("%lu\n", x); /* Gave me 10000 as expected */
  52.  
  53. return (0);
  54.  
  55. |> }
  56. -- 
  57. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  58.  
  59. Jonas J. Schlein  (schlein@gl.umbc.edu)
  60.